MIPS: scall64-o32: Fix indirect syscall number load
authorAurelien Jarno <aurelien@aurel32.net>
Tue, 9 Apr 2019 14:53:55 +0000 (16:53 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 19 Jun 2019 22:16:58 +0000 (23:16 +0100)
commit827598d3d44f4b90f71d2bd9a62061222cf6f1e7
tree0f21b537c73945dff14437593aeafccdd73af979
parent6fe2971eec634aa3f97cf6717d520e0b1ce22886
MIPS: scall64-o32: Fix indirect syscall number load

Commit 4c21b8fd8f14 (MIPS: seccomp: Handle indirect system calls (o32))
added indirect syscall detection for O32 processes running on MIPS64,
but it did not work correctly for big endian kernel/processes. The
reason is that the syscall number is loaded from ARG1 using the lw
instruction while this is a 64-bit value, so zero is loaded instead of
the syscall number.

Fix the code by using the ld instruction instead. When running a 32-bit
processes on a 64 bit CPU, the values are properly sign-extended, so it
ensures the value passed to syscall_trace_enter is correct.

Recent systemd versions with seccomp enabled whitelist the getpid
syscall for their internal  processes (e.g. systemd-journald), but call
it through syscall(SYS_getpid). This fix therefore allows O32 big endian
systems with a 64-bit kernel to run recent systemd versions.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Cc: <stable@vger.kernel.org> # v3.15+
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Paul Burton <paul.burton@mips.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: James Hogan <jhogan@kernel.org>
Cc: linux-mips@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Gbp-Pq: Topic bugfix/mips
Gbp-Pq: Name MIPS-scall64-o32-Fix-indirect-syscall-number-load.patch
arch/mips/kernel/scall64-o32.S